package com.fk.crm.settings.service.impl;

import com.fk.crm.settings.dao.DicTypeDao;
import com.fk.crm.settings.dao.DicValueDao;
import com.fk.crm.settings.domain.DicType;
import com.fk.crm.settings.domain.DicValue;
import com.fk.crm.settings.service.DicService;
import com.fk.crm.utils.SqlSessionUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DicServiceImpl implements DicService {
    private DicTypeDao dicTypeDao = SqlSessionUtil.getSqlSession().getMapper(DicTypeDao.class);
    private DicValueDao dicValueDao = SqlSessionUtil.getSqlSession().getMapper(DicValueDao.class);


    @Override
    public Map<String, List<DicValue>> getAll() {

        HashMap<String, List<DicValue>> map = new HashMap<>();
        //字典类型
        List<DicType> dtList = dicTypeDao.getTypeList();

        for (DicType dt : dtList) {
            //取得字典类型编码
            String code = dt.getCode();

            //根据code取字典列表
            List<DicValue> dvList = dicValueDao.getListByCode(code);

            map.put(code + "List",dvList);
        }
        return map;
    }
}




















